// pages/homepage/dietinfo/dietinfodetail/dietinfodetail.js
var app = getApp();
Page({
  data: {
    id:'',
    name:'',
    carbohydrate:'',
    cellulose:'',
    sugarcontent:'',
  },
  onShareAppMessage: function () {
  },
  onLoad: function (e) {
    var that = this
    var formdata;
    console.info('--------' + e.id);
    this.setData({
      id:e.id,
    }),
    formdata = e.id;
    //var formdata = options.id;
    console.log('666'),
    wx.request({
      url: app.globalData.url + '/API/dietinfo?id='+formdata,
      method: 'get',
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res.data);
        var list = res.data;
        if (list == null) {
          var toastText = '数据获取失败';
          wx.showToast({
            title: toastText,
            icon: '',
            duration: 2000
          });
        } else {
          that.setData({
            list: list
          })
        }
        /*that.setData({
          sugarcontent: res.data,
          //name
          //carbohydrate: res.data,
          //cellulose:res.data,
          //sugarcontent: res.data,
        }),*/
        console.log('888');
      },
      fail: function () {
        console.log("------------fail-------------");
      }
    })
  },
  return:function(){
    wx.navigateTo({
      url: '../../homepage',
    })
  }
})